home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / trid.zip / TRI_D.DOC < prev    next >
Text File  |  1993-01-04  |  12KB  |  397 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                           
  8.                                           
  9.                                           
  10.                                      TRI_D.TPU
  11.                                           
  12.                         A library for 3 dimensional graphics
  13.                                           
  14.                                   by Gus Smedstad
  15.        
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.                                  Table of Contents
  74.             Introduction                                               1
  75.                 Statement of purpose                                   1
  76.                 Registration                                           1
  77.                 3DEMO                                                  1
  78.             Types                                                      2
  79.             Procedures                                                 2
  80.                 Definition of viewing conditions                       2
  81.                 Drawing primitives                                     3
  82.                 Object operations                                      4
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.                                     Introduction
  140.        
  141.        Statement of purpose
  142.        
  143.             TRI_D.TPU is a toolkit for drawing and manipulating three
  144.        dimensional objects.  The intent is to be fast, yet accurate, and to
  145.        keep the actual mechanics out of the way of the user.
  146.             For example, each point within an object is stored only once,
  147.        regardless of how many polygons share that point, and transformed only
  148.        once when object or the viewpoint moves.  Similiarly, when drawing
  149.        wireframes, edges which two polygons share are stored (and drawn) only
  150.        once.  None of this requires any explicit effort on the part of the
  151.        user.
  152.        Registration
  153.        
  154.             TRI_D.TPU is distributed as shareware.  In order to use it
  155.        legally, receive support, and future updates, you must send $30
  156.        to:
  157.                  NoGate Consulting
  158.                  #13 DesIsle Ave
  159.                  Bar Harbor, Maine 04609
  160.                  (207)288-4723
  161.                  
  162.                  Make checks payable to Gus Smedstad.
  163.        
  164.             Future improvements may include an assembler version (for speed),
  165.        a Turbo C library, and hidden edge removal for concave polygons or
  166.        polygons with holes.  However, such improvements will ONLY be
  167.        distributed to registered users, and not as shareware.
  168.        
  169.             Source is available for $100.
  170.        
  171.        
  172.        3DEMO
  173.        
  174.             As part of this ARC, you should have a copy of 3DEMO.PAS, which
  175.        is a fair demonstration of the power of TRI_D.TPU.  To compile it, you
  176.        will need GRAPH.TPU and TRI_D.TPU.
  177.             Once 3DEMO is running, you will see 5 objects - a cylinder, a
  178.        hemisphere, a pyramid, a house, and a plane.  You can move and rotate
  179.        any of them, or the viewpoint, and remove the hidden edges at any
  180.        time.  Simply select an object by typing a number from 1 to 5, and use
  181.        the arrow keys to move or rotate it.  The <Page Up> and <Page Down>
  182.        keys will move the object on the Z axis.
  183.             Note that when the viewpoint is rotated to (say) look down the X
  184.        axis, moving an object with the <Right Arrow> and <Left Arrow> will
  185.        move it closer or farther from the viewpoint.  Rotation of the
  186.        viewpoint, however, stays relative to the current viewing direction,
  187.        so the <Up Arrow> key will always appear to make the objects on the
  188.        screen rotate down.
  189.             Type H to remove the hidden edges, and then press any key to
  190.        return to the wireframe drawings.
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                         - 1 -
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.             Some suggestions: try moving very close to the objects, or make
  206.        the objects intersect and try removing the edges.  Note that every
  207.        polygon has two separate sides, with separate colors.
  208.        
  209.             When you're done, type Q or the <ESC> key.
  210.        
  211.        
  212.                                        Types
  213.        TRI_D only defines one type:
  214.        
  215.             VECTOR = array[0..2] of real;
  216.        
  217.             The VECTOR type is used extensively by TRI_D to hold 3-d points
  218.        (the term vector is used in the mathematical, rather than geometric,
  219.        sense).  The [0] element holds the X coordinate, [1] the Y coordinate,
  220.        and [2] the Z coordinate.
  221.        
  222.             For ease and speed of manipulation, lines, points, and polygons
  223.        can be grouped into objects.  Objects are simply of type POINTER -
  224.        when MakeObject creates an object, it actually creates a more complex
  225.        internal data type, and returns the address, so that actual
  226.        implementation details don't intrude on the programmer.
  227.             All points and polygons are considered to be part of the last
  228.        object created with MakeObject or opened with OpenObject, or part of
  229.        the background.
  230.        
  231.                                      Procedures
  232.             The following is a list of the procedures provided by the unit
  233.        TRI_D.TPU.
  234.        
  235.        
  236.                           Definition of viewing conditions
  237.        
  238.        procedure SetViewpoint(x, y, z : real);
  239.          - The location of the "observer."
  240.        
  241.        procedure SetViewDirection(ThetaX, ThetaY, ThetaZ : real);
  242.           - Set the direction of viewing, relative to the negative Z
  243.             direction, with the Y axis being vertical, in terms of the angle
  244.             rotated about the X, Y, and Z axis.  If this does not seem very
  245.             clear, think of ThetaY as rotation, ThetaX as inclination, and
  246.             ThetaZ as yaw.  For example, SetViewDirection(pi/2,0,0) will look
  247.             along the Y axis, with the Z axis being 'up' on the screen, and
  248.             SetViewDirection(0,0,pi/2) will look along the Z axis, with the
  249.             negative X axis being 'up.'
  250.        
  251.        procedure RotateViewDirection(ThetaX, ThetaY, ThetaZ : real);
  252.           - Rotate the direction of viewing, relative to the current view
  253.             direction.  To keep subjective rotations consistent, ThetaZ
  254.             rotates around the current view direction, ThetaY rotates around
  255.             the current 'up' direction, and ThetaX rotates around the line
  256.             perpendicular to them both, instead of around the X, Y, and Z
  257.             axes as SetViewDirection does.
  258.        
  259.  
  260.  
  261.  
  262.                                         - 2 -
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.        procedure SetCenter(x, y : integer);
  272.           - position of viewpoint on screen, in screen coordinates.  May be
  273.             off-screen, if desired.
  274.        
  275.        procedure SetScale(s : real);
  276.           - width of the viewport in world coordinates.
  277.        
  278.        procedure SetDrawMode(HideEdges, Perspective : boolean);
  279.           - Set hidden plane removal and perspective or parallel views.  Note
  280.             that the drawing primitives (below) do not produce any immediate
  281.             output when edges are being removed.  Use the Regenerate
  282.             procedure to see the objects.  When Perspective is TRUE, objects
  283.             are scaled and foreshortened by distance.  A caveat - objects
  284.             will be much smaller, so set the scale appropriately.
  285.        
  286.        
  287.                                  Drawing primitives
  288.        
  289.        procedure MakePoint(x, y, z : real; color : byte);
  290.           - Create a point.  Not very meaningful when hiding edges.
  291.        
  292.        procedure SetPolyColors(pattern1, color1, pattern2, color2 : byte);
  293.           - Define colors and fill patterns for polygons.  Polygons drawn
  294.             after this command will have (Color1,pattern1) on one side and
  295.             (color2,pattern2) on the other.  See the GRAPH unit from color
  296.             and pattern definitions.  Only color1 is used for drawing lines,
  297.             and when not hiding edges.
  298.        
  299.        procedure MakePolygon(var pts; numpts : word);
  300.           - pts is assumed to be an array[1..numpts] of VECTOR.  This version
  301.             requires that Polygons be convex (that is, no interior angle >=
  302.             180 degrees) for hidden-edge removal to work perfectly, though
  303.             later versions may eliminate this restriction.
  304.        
  305.        procedure MakeLine(x1, y1, z1, x2, y2, z2 : real);
  306.           - Make a line from the first point to the second.  Same as
  307.             MakePolygon(pts,2), where pts = array[1..2] of VECTOR.
  308.        
  309.        procedure MakeTriangle(var pt1, pt2, pt3 : vector);
  310.           -  Make a triangle with points pt1, pt2, pt3.
  311.        
  312.        procedure MakeSurface(var pointlist; rows, cols : word;
  313.                              steps : integer);
  314.           - Perform a Bspline curve-fit on an array[1..rows,1..cols] of
  315.             VECTOR.  The curve is created in STEPS increments.
  316.        
  317.        
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                         - 3 -
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.                                  Object operations
  338.        
  339.        procedure Makeobject(var object : pointer);
  340.           - Creates an object.
  341.           
  342.        procedure DeleteObject(var object : pointer);
  343.           - Deletes an object (but doesn't erase it from the screen).
  344.             Selects the background for further drawing.
  345.        
  346.        procedure OpenObject(object : pointer);
  347.           - Start adding polygons/points to an OBJECT previously created with
  348.             MakeObject.  Closes any previous object.  Note that objects may
  349.             be switched as many times as you like. If given an uninitialized
  350.             object, the background is selected instead.
  351.        
  352.        procedure CloseObject;
  353.           - Select the background for drawing.
  354.        
  355.        procedure CopyObject(object : pointer);
  356.           - Copies all the polygons of an object into the current object.
  357.        
  358.        procedure DrawObject(Object : pointer);
  359.           - Draw a single object.  Note that other objects on the screen are
  360.             ignored when hiding edges, so Regenerate is more useful in that
  361.             mode.
  362.        
  363.        procedure EraseObject(Object : pointer);
  364.           - Erases a single object.  When drawing wireframes, other images
  365.             will be quickly redrawn where they overlap the erased object.
  366.        
  367.        procedure Regenerate;
  368.           - Draw ALL objects, including the background object.  Does NOT
  369.             clear the screen/viewport.
  370.        
  371.        procedure ObjectColors(Object : pointer;
  372.                               pattern1, color1, pattern2, color2 : byte);
  373.           - Changes all of the polygons in the object to a color/pattern set.
  374.        
  375.        procedure ObjectStyle(Object : pointer;
  376.                              LineStyle, pattern, thickness : byte);
  377.           - Changes the linestyle of the object (when drawn as a wireframe).
  378.        
  379.        procedure MoveObject(object : pointer; dx, dy, dz : real);
  380.           - Move an object by dx, dy, and dz.
  381.        
  382.        procedure RotateObject(object : pointer; theta,
  383.                               center, delta : vector);
  384.           - A more general object-moving procedure.  Rotate an object
  385.             Theta[0] radians about its X axis, Theta[1] about its Y axis, and
  386.             Theta[2] about its Z axis.  Center defines the center point to
  387.             rotate about, and Delta is the amount to move the object after
  388.             the rotation.
  389.        
  390.  
  391.  
  392.  
  393.  
  394.                                         - 4 -
  395.  
  396.  
  397.